<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>凉山州中考志愿填报</title>
		<link rel="stylesheet" href="css/newStyle.css" th:href="@{/css/newStyle.css}">
	</head>

	<body>
		<div class="mainBox">
			<div class="mainBox_inner student_inner">
				<h1>凉山州高中特色项目及艺体特长报名系统(学生端)</h1>
				<div>
					<div th:object="${artSpecialtySignUp}" class="clearfix studentInfo_header">
						<p class="fl">
							考生姓名：<span th:text="${artSpecialtySignUp.xm}" id="xm" class="xm">小小的雨滴</span>
						</p>
						<p class="fl">
							报名号：<span th:text="${artSpecialtySignUp.bmh}" id="bmh" class="xs_bmh">25555522522</span>
						</p>
						<form id="form1" action="xx"  method="post">
						<div class="fr">
							<!--修改密码 跳页面-->
							<input type="button" class="btn btn-primary"  onclick="javascript:history.go(-1);" value="返回上级">
						<button id="updataPassword" class="loginOut" onclick="is_submit(1)">修改密码</button>
						<button id="loginOut" class="loginOut" onclick="is_submit(2)">安全退出</button>
						</div>
						</form>
					</div>
					<div class="studentInfo_body" th:object="${wishOne}">
						<form id="tese_form" action="#" th:action="@{/saveArtSpecialty}" method="post">
							<div class="first_ami" th:object=${highSchoolWish}>
								<div class="teseClass">
									<span>特色项目班资格审核报名：</span>
									<!--disabled表示禁用-->
									<select id="schoolId" name="" class="choceSchool choceSchoolts">
										<option value="">--选择学校--</option>
										<!--这一行留着，JS需要-->
										<option th:if="${highSchoolWish == null}" th:each="school:${wishOne.featuredItems}" th:value="${school.xxdm}" th:text="${school.xxmc}" th:selected="${school.xxdm eq artSpecialtySignUp.gzxxdmts}"></option>
										<option th:unless="${highSchoolWish == null}" th:each="school:${wishOne.featuredItems}" th:value="${school.xxdm}" th:text="${school.xxmc}" th:selected="${school.xxdm eq artSpecialtySignUp.gzxxdmts}"></option>
									</select>
									<select th:name="tsxmdm" id="tsxmdm_id" class="choceMajor choceMajorts ts" disabled = "disabled">
										<option value="">--特色项目专业--</option>
										<option th:each="specialty:${wishOne.featuredItems}" th:value="${specialty.tsxmdm}" th:text="${specialty.tsxmmc}"
										th:selected="${specialty.tsxmdm eq artSpecialtySignUp.tszydm}"> </option>
									</select>
								</div>

							</div>
							<div>
								<textarea th:value="${artSpecialtySignUp.tsxmcl}" th:text="${artSpecialtySignUp.tsxmcl}" name="tese_teechang" id="tese_teechang" placeholder="考生具备何种特色或特长：（请填写特色项目证明材料）"></textarea>
							</div>
							<div class="first_ami">
								<div class="teseClass" th:object=${highSchoolWish}>
									<span>艺体特长班资格审核报名：</span>
									<select id="schoolId" name="" class="choceSchool choceSchoolyt">
										<option value="">--选择学校--</option>
										<!--这一行留着，JS需要-->
										<option th:if="${highSchoolWish == null}" th:each="school:${wishOne.specialtyOfArts}" th:value="${school.xxdm}" th:text="${school.xxmc}" th:selected="${school.xxdm eq artSpecialtySignUp.gzxxdm}"></option>
										<option th:unless="${highSchoolWish == null}" th:each="school:${wishOne.specialtyOfArts}" th:value="${school.xxdm}" th:text="${school.xxmc}" th:selected="${school.xxdm eq artSpecialtySignUp.gzxxdm}"></option>
									</select>
									<select th:name="yttcdm" class="choceMajor choceMajoryt yt" id="yttcdm_id" disabled = "disabled">
										<option value="">--艺体特长专业--</option>
										<option th:each="art:${wishOne.specialtyOfArts}" th:value="${art.yttcdm}" th:text="${art.yttcmc}" th:selected="${art.yttcdm eq artSpecialtySignUp.ytzydm}"></option>
									</select>
								</div>
							</div>

							<div>
								<textarea th:value="${artSpecialtySignUp.yttccl}" th:text="${artSpecialtySignUp.yttccl}" name="yiti_teechang" id="yiti_teechang" placeholder="具备何种艺体特长：（请填写艺体特长证明材料）" onkeyup="value=value.replace(/[^\w\u4E00-\u9FA5]/g, '')"></textarea>
							</div>
							<div>
								<button type="button" id="uploadtesInfo" class="btnclass">提交</button>
							</div>
						</form>

					</div>
				</div>
			</div>
		</div>
	</body>
	<script src="js/jquery-1.12.3.js" type="text/javascript" charset="utf-8"></script>
	<!--<script src="js/jquery-1.12.3.js"></script>-->
	<script src="js/gVerify.js"></script>
	<script src="js/commen.js"></script>
	<script>
	
	//add by bwy 增加在学校没有选择的时候，不允许选择专业，另外，在html里面的增加了默认进去不能选择学校的空间。
	$(".choceMajorts").on("click",function(){
		console.log("aaa");
		if ($(".choceSchoolts").val() == ""){
			 $(this).attr("disabled","disabled");
			alert("请先选择学校");
		}else {
			$(this).prop("disabled",false);
		}
		
	})
	
	$(".choceMajoryt").on("click",function(){
		console.log("bbbb");
		if ($(".choceSchoolyt").val() == ""){
			 $(this).attr("disabled","disabled");
			alert("请先选择学校");
		}else {
			$(this).prop("disabled",false);
		}
		
	})
	//add by bwy 增加在学校没有选择的时候，不允许选择专业
    function is_submit(value) {
        var form1 = $("#quit");
        if (value == 1) {          
            var id = $("#id").val();
            form1.action = "goChangePasswd";
             $("#form1").attr("action",form1.action);
            form1.submit();
        }
        if (value == 2) {
            form1.action = "loginOut";
            $("#form1").attr("action", form1.action);
            form1.submit();
        }
    }
    
	$(".choceMajorts option").each(function() { /*过滤指定select中重复的学校名 */
		var getText = $(this).text();
/* 		console.log(getText); */
	});
		$('.choceSchoolyt').on('click', function() {
			$(".choceSchoolyt option").each(function() { /*过滤指定select中重复的学校名 */
				var getText = $(this).text();
				if($(".choceSchoolyt option:contains(" + getText + ")").length > 1) /*select option:contains("+text+")")包含text的个数 */ {
					$(".choceSchoolyt option:contains(" + getText + "):gt(0)").remove(); /*包含text大于个数0的选项就移除*/
				}
			});
		})
		$('.choceSchoolts').on('click', function() {
			$(".choceSchoolts option").each(function() { /*过滤指定select中重复的学校名 */
				var getText = $(this).text();
				if($(".choceSchoolts option:contains(" + getText + ")").length > 1) /*select option:contains("+text+")")包含text的个数 */ {
					$(".choceSchoolts option:contains(" + getText + "):gt(0)").remove(); /*包含text大于个数0的选项就移除*/
				}
			});
		})
		$('.choceSchool').on('change', function() {
			//alert(111)
			
			var _this = this;
			var thisId = $(_this).val();
			//add by bwy 增加在学校没有选择的时候，不允许选择专业，选择学校后，要可以选择学校，所以控件要放开
			if (thisId != ""){
				$(_this).siblings().prop("disabled",false);
			}
			//add by bwy 增加在学校没有选择的时候，不允许选择专业，选择学校后，要可以选择学校，所以控件要放开
			var thissibling = $(_this).siblings('select.choceMajor');
			var majorstr = '<option value="">--选择特色项目--</option>'
			var majorytstr = '<option value="">--选择艺体特长--</option>'
			thissibling.text("")
			//var values = $('#schoolId option:selected').val(); //选中的值
			var values = $(_this).find("option:selected").val();
/* 			console.log(values); */
			
			$.ajax({
				type: 'post',
				url: "goGetHighSchoolMajor?schoolId=" + values, //取高中艺体特色专业
				dataType: 'json',
				success: function(data) {
					for(var k = 0, h = data.length; k < h; k++) {
						if(data[k].yttcdm != null && data[k].yttcdm != "null" &&
							data[k].yttcdm != "") {
							console.log("data[k].yttcmc=" + data[k].yttcmc)
							majorytstr += '<option value="' + data[k].yttcdm + '">' +
								data[k].yttcmc + '</option>';
						}
						if(data[k].tsxmdm != null && data[k].tsxmdm != "null" &&
							data[k].yttcdm != "") {
							console.log("data[k].tsxmmc=" + data[k].tsxmmc)
							majorstr += '<option value="' + data[k].tsxmdm + '">' +
								data[k].tsxmmc + '</option>';
						}
					}
					$(_this).siblings('select.choceMajor.ts').html(majorstr);
					$(_this).siblings('select.choceMajor.yt').html(majorytstr);
				},
				error: function(error) {
					console.log(error);
				}
			})
		});

		//艺体、特色班级二选一
		$('.teseClass').on('change', 'select', function() {
			var _this = this;
			var schoolval = $(_this).parent().find('.choceSchool').val();
			if(schoolval != '') {
				$('.yitiClass').find('select').attr('disabled', true).css({
					backgroundColor: "#7492ac"
				});
			} else {
				$('.yitiClass').find('select').attr('disabled', false).css({
					backgroundColor: "#005bab"
				});
			}
		})
		$('.yitiClass').on('change', 'select', function() {
			var _this = this;
			var schoolval = $(_this).parent().find('.choceSchool').val();
			if(schoolval != '') {
				$('.teseClass').find('select').attr('disabled', true).css({
					backgroundColor: "#7492ac"
				});
			} else {
				$('.teseClass').find('select').attr('disabled', false).css({
					backgroundColor: "#005bab"
				});
			}
		})
		
		

		$('#uploadtesInfo').on('click', function() {
			// var schoolSelect = $("#schoolId").find("option:selected").text();
			var schoolSelect1 = $(".choceSchoolts").find("option:selected").val();
			var schoolSelect2 = $(".choceSchoolyt").find("option:selected").val();
			var majorTs=$("#tsxmdm_id").find("option:selected").val();
			var majorYt=$("#yttcdm_id").find("option:selected").val();
			if((schoolSelect1 == null || schoolSelect1 == "")&& (schoolSelect2 == null || schoolSelect2 == "")) {
				alert("未做任何选择，不能保存!");
				return false;
			}
			if ((schoolSelect1 != null && schoolSelect1 != "") && (majorTs == null || majorTs =="")){
				alert("选择了特色项目学校必须选择特色项目专业!");
				return false;
			}
			if ((schoolSelect2 != null && schoolSelect2 != "") && (majorYt == null || majorYt =="")){
				alert("选择了艺体特长学校必须选择艺体特长专业!");
				return false;
			}
			//if ($('.choceSchoolts').val() == $('.choceSchoolyt').val()){
			//	alert("两个学校不能相同，请重新输入！");
			//	return false;
			//}
			var skillDetail = $("#tese_teechang").val();
			//console.info($("#xm").text());
			//console.log($("#tsxmdm_id option:selected").val());
			//console.log($("#tsxmdm_id option:selected").text());
			//console.log($("#yttcdm_id option:selected").val());
			//console.log($("#yttcdm_id option:selected").text());
			//console.log($("#yiti_teechang").val());

			$.ajax({
				//几个参数需要注意一下
				type: "POST", //方法类型
				dataType: "json", //预期服务器返回的数据类型
				url: "/saveArtSpecialty", //url
				data: {
					"xm": $("#xm").text(),
					"bmh": $("#bmh").text(),
					"gzxxdm": $(".choceSchoolyt option:selected").val(),
					"gzxxdmts": $(".choceSchoolts option:selected").val(),
					"tsxmdm": $("#tsxmdm_id option:selected").val(),
					"tsxmmc": $("#tsxmdm_id option:selected").text(),
					"yttcdm": $("#yttcdm_id option:selected").val(),
					"yttcmc": $("#yttcdm_id option:selected").text(),
					"yttccl": $("#yiti_teechang").val(),
					"gzxxmc": $(".choceSchoolyt").find("option:selected").text(),
					"gzxxmcts": $(".choceSchoolts").find("option:selected").text(),
					"tsxmcl": skillDetail
				},
				success: function(data) {
					//alert("保存成功！");

					if(data.code == 'ok') {
						alert(data.message);
						window.location.href = data.url;
					} else if(data.code == 'error') {
						alert(data.message);
						window.location.href = data.url;
					} else {
						alert(data.message);
					}

				},
				error: function() {
					//alert("异常！");
					console.log("返回有异常");
				}
			});
			//数据判读完成后，提交数据
			// $('#tese_form').submit();
		})

		/*提交*/

		/**
	$(".btnclass").on("click",function(){
		var data = new Object();
		data.act = "tsytzc";
		data.name_xm = $(".xs_xm").text();
		data.bmh = $(".xs_bmh").text();
		data.chooscholl_xmdm = $(".choceSchool option:selected").val();
		data.chooscholl_xmmc = $(".choceSchool option:selected").text();
		data.choceMajorts_xmdm = $(".choceMajorts option:selected").val();
		data.choceMajorts_xmmc = $(".choceMajorts option:selected").text();
		data.choceMajoryt_xmdm = $(".choceMajoryt option:selected").val();
		data.choceMajoryt_xmmc = $(".choceMajoryt option:selected").text();
		data.tese_teechang =$("#tese_teechang").val();
		data.yiti_teechang =$("#yiti_teechang").val();
		var data_str = JSON.stringify(data);
		
		$.ajax({
				type:"post",
				url:"saveArtSpecialty",
				data: data_str,
		        dataType: "json",
		        success:function (data) { 
			        if (data == true) {
			            alert("填报成功！");
			        }else {
			            alert("对不起"+data);
			        }
	           }
		});
	})  
*/
	</script>

</html>